{% extends 'siteAdmin/siteAdmin.html' %}
{% block operation %}
{% include 'siteAdmin/tinyPart.html' with context %}
{% if req.path ==pageData['subdomain']+'/siteAdmin/moduleAdd' %}
       <div id="box">
        {% if pageData['module'].id %}
            <form  method="POST" action="{{pageData['subdomain']}}/siteAdmin/moduleAdd?update={{pageData['module'].id}}">
        {% else %}
            <form  method="POST" action="{{pageData['subdomain']}}/siteAdmin/moduleAdd?add">
        {% endif %}
<div>
                <span class="word">Nome del modulo</span>
                <span class="insert">
                <input name="moduleTitle" type="text" value ="{{pageData['module'].denomination|nonone}}" style="width: 20%"/></span><br /><br />
                <span class="word">Codice modulo</span>
                <span class="insert">
                <input name="moduleCodice" type="text" value ="{{pageData['module'].codice|nonone}}" style="width: 10%"/></span><br /><br />
                <span class="word">Versione modulo</span>
                <span class="insert">
                <input name="moduleVersione" type="text" value ="{{pageData['module'].versione|nonone}}" style="width: 10%"/></span><br /><br />
                <span class="word">LITE:</span>
                <span class="insert">:
                {% if pageData['module'].lite %}
                    <input name="moduleLite" type="checkbox" value ="True" checked="checked"/> </span><br /><br />
                {% else %}
                    <input name="moduleLite" type="checkbox" value = "False" /> </span><br /><br />
                {% endif %}
                <span class="word">PRO:</span>
                <span class="insert">
                {% if pageData['module'].normal %}
                <input name="moduleNormal" type="checkbox" value ="True" checked="checked"/> </span><br /><br />
                {% else %}
                <input name="moduleNormal" type="checkbox" value="False"/> </span><br /><br />
                {% endif %}
                <span class="word">Prezzo modulo</span>
                <span class="insert">
                <input name="modulePrezzo" type="text" value ="{{pageData['module'].prezzo|nonone}}" style="width: 10%"/></span><br /><br />
                <span class="word">Prezzo rinnovo modulo</span>
                <span class="insert">
                <input name="modulePrezzoRinnovo" type="text" value ="{{pageData['module'].prezzo_rinnovo|nonone}}" style="width: 10%"/></span><br /><br />
                <span class="word">Abstract</span><br />
                <textarea name="moduleAbstract" type="text" rows="10" cols="40" style="width: 80%">{{pageData['module'].abstract|nonone}}</textarea><br /><br />
                <span class="word">CORPO</span><br />
                <textarea name="moduleBody" rows="30" cols="40" style="width: 80%">{{pageData['module'].body|nonone}}</textarea>
                </div>
                    <div>
                    <span class="word">Seleziona la Associazione Modulo:</span><br /><br />
                        <select name="categoriaId" style="width: 70%" size="25" multiple="multiple">
                            {% for modu in pageData['listamoduli'] %}
                                {% if pageData['module'].id != modu.id %}
                                {% if modu.id in pageData["moduliassociati"] %}
                                <option value="{{modu.id}}" SELECTED >{{modu.denomination}}</option>
                                {% else %}
                                <option value="{{modu.id}}" >{{modu.denomination}}</option>
                                {% endif %}

                                {% endif %}
                            {% endfor %}
                        </select>
</div>
            <div class="row thin lineTop"><br /><br />
                <span class="word">Seleziona la lingua predefinita:</span>
                    <select name="languageId">
                    {% for lang in pageData['language'] %}
                    <option value="{{lang.id}}">{{lang.denominazione}}</option>
                    {% endfor %}
                    </select>
            </div>
           <br /><br /><br />
                <div style="height:auto;">
                <img src="/templates/img/module_img/{{pageData['module'].imagepath}}?{{pageData['now']}}" alt="{{pageData['module'].title}}" class="img_left" /><br /><br /> </div>
                <div><a HREF="{{pageData['subdomain']}}/siteAdmin/fileupload?id={{pageData['module'].id}}&amp;part=moduleAdd"
                    onClick="return targetopener(this)">Aggiungi o modifica la foto abbinata</a></div>
            <br /><br /><br /><br />
            <div>
                 <span class="word">Aggiungi i link alle foto ed ai video ( ti ricordo che per la foto basta il nome e dev'essere caricata nella cartella /templates/promoGest/img/moduli_screen/)</span><br /><br />
                {% for vid in pageData['mediaAbbinati'] %}
                {% if vid==1 or vid.numero ==1 %}
                    <span class="word">Media 1</span>
                    <span class="insert"><input name="moduleMedia1" type="text" value ="{{vid.imagepath|escape}}" style="width: 80%"/></span><br /><br />
                {% elif vid==2 or vid.numero ==2 %}
                <span class="word">Media 2</span>
                <span class="insert"><input name="moduleMedia2" type="text" value ="{{vid.imagepath|escape}}" style="width: 80%"/></span><br /><br />
                {% elif vid ==3 or vid.numero ==3 %}
                <span class="word">Media 3</span>
                <span class="insert"><input name="moduleMedia3" type="text" value ="{{vid.imagepath|escape}}" style="width: 80%"/></span><br /><br />
                {% elif vid ==4 or vid.numero ==4 %}
                <span class="word">Media 4</span>
                <span class="insert"><input name="moduleMedia4" type="text" value ="{{vid.imagepath|escape}}" style="width: 80%"/></span><br /><br />
                {% elif vid==5 or vid.numero ==5 %}
                <span class="word">Media 5</span>
                <span class="insert"><input name="moduleMedia5" type="text" value ="{{vid.imagepath|escape}}" style="width: 80%"/></span><br /><br />
            {% endif %}
            {% endfor %}
</div>
                <input type="submit" class="wymupdate" value="Aggiungi/modifica"/></form>
        </div>

{% elif req.path ==pageData['subdomain']+'/siteAdmin/moduleList' %}
    <div id="box">
        <span class="testa"><h1>Gestione Moduli</h1></span>
            <hr></hr>
            <div class="row normal">
                <a href="{{pageData['subdomain']}}/siteAdmin/moduleAdd?new">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi un modulo" title="aggiungi un modulo"/>
                </a>
            </div>
    {% for page in pageData['module'] %}
        <div class="row normal lineTop" >
            <span >{{page.denomination}} {{page.insert_date|datetimeformat}}</span>
            <span class="image normal"><a href="{{pageData['subdomain']}}/siteAdmin/moduleDel?moduleId={{page.id}}" onClick='return confirm("Sei sicuro di voler cancellare questo modulo?")' ><img src="/templates/siteAdmin/img/trash.png" alt="elimina la news" title="elimina  il modulo"/></a></span>
            <span class="image normal"><a href="{{pageData['subdomain']}}/siteAdmin/moduleAdd?edit={{page.id}}"><img src="/templates/siteAdmin/img/modifica.png" alt="modifica un modulo" title="modifica un modulo"/></a></span>
        {% if page.active==1 %}
            <span class="image normal" >
                <a href="{{pageData['subdomain']}}/siteAdmin/moduleActive?id={{page.id}}&amp;pag={{pageData['pag']+1}}">
                    <img src="/templates/siteAdmin/img/active_on.png" alt="disattiva modulo" title="disattiva News"/>
                </a>
            </span>
        {% endif%}
        {% if page.active==0 %}
            <span class="image normal">
                <a href="{{pageData['subdomain']}}/siteAdmin/moduleActive?id={{page.id}}&amp;pag={{pageData['pag']+1}}">
                    <img src="/templates/siteAdmin/img/active_off.png" alt="attiva modulo" title="attiva Modulo"/>
                </a>
            </span>
        {% endif%}
        <span class="image normal">
                <a href="{{pageData['subdomain']}}/siteAdmin/modulePosition?id={{page.id}}&amp;pag={{pageData['pag']+1}}&amp;pos=giu">
                    <img src="/templates/siteAdmin/img/giu.png" alt="attiva modulo" title="attiva Modulo"/>
                </a>
            </span>

        <span class="image normal">
                <a href="{{pageData['subdomain']}}/siteAdmin/modulePosition?id={{page.id}}&amp;pag={{pageData['pag']+1}}&amp;pos=su">
                    <img src="/templates/siteAdmin/img/su.png" alt="attiva modulo" title="attiva Modulo"/>
                </a>
            </span>


        </div>
    {% endfor %}
        <ul class="pages">
            <li class="prima">Moduli</li>
            {% for i in range(0,pageData['item']) %}
                {% if i != pageData['pag'] %}
                    <li><a href="{{pageData['subdomain']}}/siteAdmin/moduleList?pag={{i+1}}">{{i+1}}</a></li>
                {% else %}
                    <li>[<a href="{{pageData['subdomain']}}/siteAdmin/moduleList?pag={{i+1}}">{{i+1}}</a>]</li>
                {% endif %}
            {% endfor %}
        </ul>
            <div class="row normal lineTop">
                <a href="{{pageData['subdomain']}}/siteAdmin/moduleAdd?new">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi una pagina" title="aggiungi una pagina"/>
                </a>
            </div>
    </div>

{% endif %}
<!--         </div> -->
{%endblock%}
